/*
 * 
 * LegendShop 多用户商城系统
 * 
 *  版权所有,并保留所有权利。
 * 
 */
package com.legendshop.oa.controller;

import java.util.ResourceBundle;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.legendshop.dao.support.CriteriaQuery;
import com.legendshop.framework.controller.AdminController;
import com.legendshop.framework.controller.BaseController;
import com.legendshop.oa.model.ProjectCost;
import com.legendshop.oa.service.ProjectCostService;

/**
 * The Class ProjectCostController
 * 项目费用表控制器
 */
@Controller
@RequestMapping("/admin/projectCost")
public class ProjectCostController extends BaseController implements AdminController<ProjectCost, Long> {
    @Autowired
    private ProjectCostService projectCostService;

	/**
	 * 项目费用表列表查询
	 */
    @RequestMapping("/query")
    public String query(HttpServletRequest request, HttpServletResponse response, String curPageNO, ProjectCost projectCost) {
        CriteriaQuery cq = new CriteriaQuery(ProjectCost.class, curPageNO);
        //cq.setPageSize(PropertiesUtil.getObject(SysParameterEnum.PAGE_SIZE, Integer.class));
        //DataFunctionUtil.hasAllDataFunction(cq, request, StringUtils.trim(cash.getUserName()));
        /*
           //TODO add your condition
        */
/*        PageSupport ps = projectCostService.getProjectCost(cq);
        PageSupportHelper.savePage(request, ps);
        request.setAttribute("projectCost", projectCost);*/
        
        return "/projectCost/projectCostList";
        //TODO, replace by next line, need to predefined BackPage parameter
       // return PathResolver.getPath(request, response, BackPage.PROJECTCOST_LIST_PAGE);
    }

	/**
	 * 保存项目费用表
	 */
    @RequestMapping(value = "/save")
    public String save(HttpServletRequest request, HttpServletResponse response, ProjectCost projectCost) {
        projectCostService.saveProjectCost(projectCost);
        saveMessage(request, ResourceBundle.getBundle("i18n/ApplicationResources").getString("operation.successful"));
        return "forward:/admin/projectCost/query.htm";
        //TODO, replace by next line, need to predefined FowardPage parameter
		//return PathResolver.getPath(request, response, FowardPage.PROJECTCOST_LIST_QUERY);
    }

	/**
	 * 删除项目费用表
	 */
    @RequestMapping(value = "/delete/{id}")
    public String delete(HttpServletRequest request, HttpServletResponse response, @PathVariable
    Long id) {
        ProjectCost projectCost = projectCostService.getProjectCost(id);
        //String result = checkPrivilege(request, UserManager.getUsername(request.getSession()), projectCost.getUserName());
		//if(result!=null){
			//return result;
		//}
		projectCostService.deleteProjectCost(projectCost);
        saveMessage(request, ResourceBundle.getBundle("i18n/ApplicationResources").getString("entity.deleted"));
        return "forward:/admin/projectCost/query.htm";
        //TODO, replace by next line, need to predefined FowardPage parameter
        //return PathResolver.getPath(request, response, FowardPage.PROJECTCOST_LIST_QUERY);
    }

	/**
	 * 根据Id加载项目费用表
	 */
    @RequestMapping(value = "/load/{id}")
    public String load(HttpServletRequest request, HttpServletResponse response, @PathVariable
    Long id) {
        ProjectCost projectCost = projectCostService.getProjectCost(id);
        //String result = checkPrivilege(request, UserManager.getUsername(request.getSession()), projectCost.getUserName());
		//if(result!=null){
			//return result;
		//}
        request.setAttribute("projectCost", projectCost);
        return "/projectCost/projectCost";
         //TODO, replace by next line, need to predefined FowardPage parameter
         //return PathResolver.getPath(request, response, BackPage.PROJECTCOST_EDIT_PAGE);
    }
    
   /**
	 * 加载编辑页面
	 */
	@RequestMapping(value = "/load")
	public String load(HttpServletRequest request, HttpServletResponse response) {
		return "/projectCost/projectCost";
		//TODO, replace by next line, need to predefined BackPage parameter
		//return PathResolver.getPath(request, response, BackPage.PROJECTCOST_EDIT_PAGE);
	}

   /**
	 * 更新编辑页面
	 */
    @RequestMapping(value = "/update")
    public String update(HttpServletRequest request, HttpServletResponse response, @PathVariable Long id) {        
        ProjectCost projectCost = projectCostService.getProjectCost(id);
		//String result = checkPrivilege(request, UserManager.getUsername(request.getSession()), projectCost.getUserName());
		//if(result!=null){
			//return result;
		//}
		request.setAttribute("projectCost", projectCost);
		return "forward:/admin/projectCost/query.htm";
		//TODO, replace by next line, need to predefined BackPage parameter
		//return PathResolver.getPath(request, response, BackPage.PROJECTCOST_EDIT_PAGE);
    }

}
